﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace SqlconTest
{
    class DbHelper
    {
        //连接字符串
        public static string constr = "Server=.;user Id=sa;pwd=123456;database=Test;";
        //加载驱动
        public static SqlConnection sqlcon = new SqlConnection(constr);
        //封装
        public static DataTable GetTable(string sql)
        {
            sqlcon.Open();
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql,sqlcon);
            DataTable dt = new DataTable();
            sqlDataAdapter.Fill(dt);
            sqlcon.Close();
            return dt;
        }
    }
}
